package com.pug.product.rest;

import com.pug.product.dto.ProductPageRespDTO;
import com.pug.product.dto.ProductReqDTO;
import com.pug.product.dto.ProductRespDTO;
import com.pug.product.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xq.pug.common.dto.PageDTO;
import xq.pug.common.result.R;

import java.util.List;

/**
 * @program: xq_pug_alibabacloud_parent
 * @description:
 * @author: Mr.Ren
 * @create: 2023-06-03 14:41
 **/
@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private IProductService productService;

    @PostMapping("/page")
    public R<ProductPageRespDTO> selectBuPage(@RequestBody PageDTO dto){
        ProductPageRespDTO respDTO = productService.queryPage(dto);
        return R.ofSuccess(respDTO);
    }

    @PostMapping("/queryProduct")
    public R<List<ProductRespDTO>> queryProduct(@RequestBody ProductReqDTO dto){
        List<ProductRespDTO> products = productService.queryProducts(dto);
        return R.ofSuccess(products);
    }
}
